package com.powerwyx.lambda.stream;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class testStream {
    public static void main(String[] args) {
        //1.筛选filter
        /*int[] arrs = {1,5,6,9,8,5};
        IntStream stream = Arrays.stream(arrs);
        stream.filter(arr -> arr > 5).forEach(System.out::println);

        Stream<String> stream1 = Stream.of("zhangsan", "lisi", "ls", "wangwu");
        stream1.filter(s -> s.length() > 4).forEach(System.out::println);
*/
        //2.映射map
        /*Stream.of("zhangsan","lisi","wangwu").map(String::toUpperCase).forEach(System.out::println);

        //3.去重
        Stream.of("aa","bb","cc","cc","dd","aa").distinct().forEach(System.out::println);*/


        //4.排序sorted
        //升序
        /*Stream.of(1,55,66,15,-2,-25).sorted().forEach(System.out::println);
        Stream.of("aaa","cc","asdasda","da").sorted().forEach(System.out::println);*/


        //5.合并
       /* Stream<Integer> stream1 = Stream.of(1, 2, 3);
        Stream<Integer> stream2 = Stream.of(4, 5, 6);
        Stream.concat(stream2,stream1).forEach(System.out::println);*/


        //6.截断和跳过
        //跳过前两个，从当前位置开始取三个
        Stream.of(1,22,33,744,15,16).skip(2).limit(3).forEach(System.out::println);


    }
}
